import Vue from 'vue'
import App from './App'
import store from './store'
import components from './components'
import * as Fitter from './filters.js'
import router from './router'
import Vant from 'vant';
import http from 'http';
import 'vant/lib/vant-css/index.css';
import { Lazyload } from 'vant';

Vue.use(Lazyload);
Vue.use(Vant);
// 自定义组件扩展
Object.keys(components).forEach((key) => {
  var name = key.replace(/(\w)/, (v) => v.toUpperCase()) // 首字母大写
  Vue.component(`${name}`, components[key])
});

// 设置标题头
router.beforeEach((to, from, next) => {
  document.title = to.meta.title || '商城'
  next()
})

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  http,
  Fitter,
  components: {
    App
  },
  template: '<App/>'
})
